#!/usr/bin/env bash

set -e

# Ensure that we are running this from the root of the project. If the script is
# run from anywhere else, the cassettes end up in the wrong directory.
echo "---> Running setup checks"
if [[ ! -f "README.md" ]] ; then
  echo "     Test suite is not being run from the project root."
  echo "     Please change to the root and re-run the test suite."
  exit 1
fi
echo "---> Pre-checks all passed"

# Bundle it all up.
echo "---> Fetching all dependencies"
bundle install | sed "s/^/     /"
echo "---> Bundling completed"

# Run the test suite.
echo "---> Starting test suite"
bundle exec rspec spec | sed "s/^/     /"
echo "---> Test suite completed"
